package ys.ewp.dto;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;

import ys.ewp.po.TaskLevel;

public class TaskLevelDto {
	//任务等级ID
	private Integer id;
	//任务等级
	private String title;
	//创建时间
	private Date dateCreated;
	//更新时间
	private Date dateUpdated;
	//删除标记
	private boolean deleted = false;
	
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	
	public Date getDateCreated() {
		return dateCreated;
	}
	public void setDateCreated(Date dateCreated) {
		this.dateCreated = dateCreated;
	}
	public Date getDateUpdated() {
		return dateUpdated;
	}
	public void setDateUpdated(Date dateUpdated) {
		this.dateUpdated = dateUpdated;
	}
	public boolean isDeleted() {
		return deleted;
	}
	public void setDeleted(boolean deleted) {
		this.deleted = deleted;
	}
	/**
	 * 根据任务等级Po获取任务等级Dto
	 * @param taskLevel 任务等级
	 * @return
	 */
	public static TaskLevelDto getDtoByPo(TaskLevel taskLevel){
		TaskLevelDto tlDto = new TaskLevelDto();
		tlDto.setId(taskLevel.getId());
		tlDto.setTitle(taskLevel.getTile());
		tlDto.setDateCreated(taskLevel.getDateCreated());
		tlDto.setDateUpdated(taskLevel.getDateUpdated());
		tlDto.setDeleted(taskLevel.isDeleted());
		return tlDto;
	}
	/**
	 * 根据任务等级Dto获取任务等级Po
	 * @param tlDto 任务等级Dto
	 * @return
	 */
	public static TaskLevel getPoByDto(TaskLevelDto tlDto){
		TaskLevel tl = new TaskLevel();
		tl.setId(tlDto.getId());
		tl.setTile(tlDto.getTitle());
		tl.setDateCreated(tlDto.getDateCreated());
		tl.setDateUpdated(tlDto.getDateUpdated());
		tl.setDeleted(tlDto.isDeleted());
		return tl;
	}
	
	/**
	 * 	@功能 根据PO列表获取DTO列表
	 * @param taskList 
	 * @return 
	 */
	public static List<TaskLevelDto> getDtoListByPoList(List<TaskLevel> tlList){
		if(tlList == null || tlList.isEmpty()){
			return Collections.emptyList();
		}
		List<TaskLevelDto> tlDtoList = new ArrayList<TaskLevelDto>();
		for(TaskLevel tl : tlList){
			tlDtoList.add(getDtoByPo(tl));
		}
		return tlDtoList;
	}
	/**
	 * @功能 根据DTO列表获取PO列表
	 * @param taskDtoList
	 * @return
	 */
	public static List<TaskLevel> getPoListByDtoList(List<TaskLevelDto> tlDtoList){
		if(tlDtoList == null || tlDtoList.isEmpty()){
			return Collections.emptyList();
		}
		List<TaskLevel> tlList = new ArrayList<TaskLevel>();
		for(TaskLevelDto tlDto : tlDtoList){
			tlList.add(getPoByDto(tlDto));
		}
		return tlList;
	}
}
